package com.smartstate.EnvironmentMonitor.controller;

import com.smartstate.EnvironmentMonitor.dto.DataDTO;
import com.smartstate.EnvironmentMonitor.dto.ReportDTO;
import com.smartstate.EnvironmentMonitor.entity.Report;
import com.smartstate.EnvironmentMonitor.service.HistoryService;
import com.smartstate.EnvironmentMonitor.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@Api(value = "历史曲线")
@RequestMapping("/history")
public class HistoryController {

    @Resource
    private HistoryService historyService;

//    /**
//     * 获取历史曲线
//     * @param dataDTO
//     * @return
//     */
//    @ApiOperation(value = "获取历史曲线")
//    @PostMapping("/getHistoryCurve")
//    public ResultVO getHistoryCurve(@RequestBody DataDTO dataDTO){
//        Map<String, List<Report>> historyCurve = historyService.getHistoryCurve(dataDTO);
//        return ResultVO.ok(historyService.getHistoryCurve(dataDTO));
//    }

//    @PostMapping("/getHistoryCurveByDeviceId")
//    public void test(){
//        log.info(historyService.getHistoryCurveByDeviceId("DHU0005").toString());
//        log.info(String.valueOf(historyService.getHistoryCurveByDeviceId("DHU0005").size()));
//    }

    /**
     * 自定义查询历史曲线
     * @param dataDTO
     * @return
     */
    @ApiOperation(value = "自定义查询历史曲线")
    @PostMapping("/queryByDataDTO")
    public ResultVO queryByDataDTO(@RequestBody DataDTO<ReportDTO> dataDTO){

        return ResultVO.ok(historyService.getHistoryCurveByDataDTO(dataDTO));

    }


}
